<template>
  <section>
    <section v-for="subject in subjects" :key="subject.key">
      <el-button
        :type="subject.key === activeKey ? 'primary' : ''"
        @click="activeKey = subject.key"
      >
        {{ subject.key }}
      </el-button>
      <Examination :subjectList="currentErrorList"></Examination>
    </section>
  </section>
</template>

<script setup lang="ts">
import { localStorage } from '@/utils/metheds';
import { computed, ref } from 'vue';
import Examination from './tempExamination.vue';
import { SubjectItem, Subject } from './interfaceType';
const subjects = localStorage('subjects', 'getItem');
const currentSubject = computed(() => {
  return subjects?.find((item: Subject) => item.key);
});
const currentErrorList = currentSubject.value?.list.filter(
  (item: SubjectItem) => item.errorCount,
);
const activeKey = ref();
</script>
